<template>
	<view class="" style="padding-bottom: 150rpx;">
		<view class="mainpadding">
			<!-- 头部 -->
			<view class="flexbetween" v-if="!is_login">
				<view class="flexleft" @click="jumper('/pages/login/login')">
					<image class="touxiang margin_right2" src="@/static/image/sysem/weidenglu.png" mode=""></image>
					<view class="bigtext" style="color: #D3D3D3;">未登录，点击登录</view>
				</view>
				<u-icon name="arrow-right" color="#938F90"></u-icon>
			</view>
			<view class="flexbetween" v-if="is_login">
				<view class="flexleft" @click="jumper('/pages_mypage/gerenxx')">
					<image class="touxiang margin_right2" :src="userInfo.avatar_text" mode=""></image>
					<view class="">
						<view class="bigtext" style="color: #D3D3D3;">{{userInfo.nickname}}</view>
						<view class="strongtext margin_top1" style="color: #888888;">ID：{{userInfo.id}}</view>
						<view class="strongtext margin_top1" style="color: #888888;" @click.stop="copy(userInfo.invite_code)">邀请码：{{userInfo.invite_code}}</view>
					</view>
				</view>
				<view class="flexright" @click="zhuye('/pages_homepage/gerenzhuye?id=',userInfo.id)">
					<view class="strongtext margin_right1" style="color: #938F90;">主页</view>
					<u-icon name="arrow-right" color="#938F90"></u-icon>
				</view>
			</view>
			<view class="radius tybjs mainpadding margin_top flexbetween">
				<!-- <view class="sanshis flexcenter" @click="jumper('/pages_mypage/gerenxx')">
					<view class="titletext xiaobai">动态 0</view>
				</view> -->
				<view class="sanshis flexcenter" @click="jumper('/pages_mypage/guanzhu')">
					<view class="titletext xiaobai">关注 {{userInfo.mygz_num || 0}}</view>
				</view>
				<view class="sanshis flexcenter" @click="jumper('/pages_message/fensi')">
					<view class="titletext xiaobai">粉丝 {{userInfo.myfs_num || 0}}</view>
				</view>
			</view>
			<!--  -->
			<view class="flexbetween margin_top" v-if="is_login">
				<view class="yipbox" @click="jumper('/pages_mypage/huiyuan')">
					<view class="ershiba xiaobai fonweight">VIP卡</view>
					<view class="smalltext margin_top2" style="color: #EBEBEB;">
						{{userInfo.level==0?"暂未开通":userInfo.vip_time_text+"到期"}}</view>
				</view>
				<view class="yipbox1" @click="jumper('/pages_mypage/yue')">
					<view class="ershiba xiaobai fonweight">我的钱包</view>
					<view class="smalltext margin_top2" style="color: #EBEBEB;">余额：{{userInfo.money}}</view>
				</view>
			</view>
			<view class="flexbetween margin_top5 xiahuaxian" @click="tzscym(1)">
				<view class="flexleft">
					<view class="cion margin_right1">
						<image src="../static/image/sysem/wdsc.png" mode=""></image>
					</view>
					<view class="sanshier xiaobai">收藏</view>
				</view>
				<u-icon name="arrow-right" color="#938F90" size="14"></u-icon>
			</view>
			<view class="flexbetween margin_top xiahuaxian" @click="jumper('/pages_mypage/goumaijl')">
				<view class="flexleft">
					<view class="cion margin_right1">
						<image src="../static/image/sysem/wdgm.png" mode=""></image>
					</view>
					<view class="sanshier xiaobai">我的购买</view>
				</view>
				<u-icon name="arrow-right" color="#938F90" size="14"></u-icon>
			</view>
			<view class="flexbetween margin_top xiahuaxian" @click="tzscym(2)">
				<view class="flexleft">
					<view class="cion margin_right1">
						<image src="../static/image/sysem/lsjl.png" mode=""></image>
					</view>
					<view class="sanshier xiaobai">历史记录</view>
				</view>
				<u-icon name="arrow-right" color="#938F90" size="14"></u-icon>
			</view>
			<!-- <view class="flexbetween margin_top xiahuaxian" @click="contactshow=true">
				<view class="flexleft">
					<view class="cion margin_right1">
						<image src="../static/image/sysem/sptg.png" mode=""></image>
					</view>
					<view class="sanshier xiaobai">联系客服</view>
				</view>
				<u-icon name="arrow-right" color="#938F90" size="14"></u-icon>
			</view> -->
			<view class="flexbetween margin_top xiahuaxian" @click="enterchat">
				<view class="flexleft">
					<view class="cion margin_right1">
						<image src="../static/image/sysem/sptg.png" mode=""></image>
					</view>
					<view class="sanshier xiaobai">联系客服</view>
				</view>
				<u-icon name="arrow-right" color="#938F90" size="14"></u-icon>
			</view>
			<view class="flexbetween margin_top xiahuaxian" @click="jumper('/pages_mypage/shezhi')">
				<view class="flexleft">
					<view class="cion margin_right1">
						<image src="../static/image/sysem/sz.png" mode=""></image>
					</view>
					<view class="sanshier xiaobai">设置</view>
				</view>
				<u-icon name="arrow-right" color="#938F90" size="14"></u-icon>
			</view>

		</view>
		<u-popup :show="contactshow" @close="contactshow=false" :round="20" bgColor="#282536">
			<view class="mainpadding">
				<view class="xiaobai flexcenter sanshier margin_top">联系客服</view>
				<view class="flexcenter margin_top">
					<image :src="system.whatcode" style="width:300rpx;height:300rpx;" mode=""></image>
				</view>
				<view class="xiaobai ershil margin_top6 textcenter">扫描上方二维码添加客服微信</view>
				<view class="xiaobai ershil margin_top textcenter">或点击此处电话<text @click="callphone(system.kf_tel)"
						style="color:#DD5056;">联系客服</text></view>
				<!-- <view class="flexbetween ">
					<view class="bigbtn">电话联系客服</view>
				</view> -->
			</view>
		</u-popup>
		<tabbar :current="4"  ref="tabbardiref"></tabbar>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				is_login: false,
				userInfo: {},
				show: false,
				title: '确定要退出当前账户么？',
				contactshow: false,
				system: {}

			}
		},
		onLoad() {
			uni.hideTabBar()
		},
		onShow() {
			setTimeout(()=>{
				this.$refs.tabbardiref.noreadNum = 0
				this.$refs.tabbardiref.getnoreadNum()
			},100)
			this.is_login = httpRequest.checkIsLogin();
			console.log(this.is_login);
			if (this.is_login) {
				this.init()
			} else {
				this.userInfo = {}
			}
			// this.getsystem()
		},
		methods: {
			enterchat() { //进入聊天
				if (!httpRequest.checkIsLogin()) {
					uni.navigateTo({
						url: "/pages/login/login"
					})
					return false
				}
				if(this.userInfo.id==1){
					httpRequest.toast("自己不能和自己聊天")
					return false
				}
				let that = this
				uni.showLoading({
					mask:true,
					title:"请稍后"
				})
				httpRequest.request('/api/user/addFriends', 'GET', {
					firend_id:1
				}).then(res => {
					uni.hideLoading()
					let data = {
						firend_id: 1,
						friend_name: "客服",
						firend_avatar_text: "https://www.fun6688.fun/uploads/20240621/a3ded7bfbf20ba8e59fad3381ac75880.png"
					}
					uni.navigateTo({
						url: "/pages_message/chat?msg=" + encodeURIComponent(JSON.stringify(data))
					})
				})
				
			},
			getsystem() {
				httpRequest.request('/api/index/getConfigInfo', 'GET', {}).then(res => {
					this.system = res.data
				})
			},
			init() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					this.userInfo = res.data
				})
			},
			// 跳转收藏
			tzscym(i) {
				if (!httpRequest.checkIsLogin()) {
					uni.navigateTo({
						url: "/pages/login/login"
					})
					return false
				}
				uni.navigateTo({
					url: '/pages_mypage/shoucang?id=' + i
				})
			},
			jumper(url) {
				if (!httpRequest.checkIsLogin()) {
					uni.navigateTo({
						url: "/pages/login/login"
					})
					return false
				}
				uni.navigateTo({
					url: url
				})
			},
			zhuye(url, val) {
				if (!httpRequest.checkIsLogin()) {
					uni.navigateTo({
						url: "/pages/login/login"
					})
					return false
				}
				uni.navigateTo({
					url: url + val
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.cion {
		width: 38rpx;
		height: 38rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.yipbox1 {
		width: 48%;
		padding: 24rpx 32rpx 22rpx 72rpx;
		background-size: 100% 100%;
		background-image: url('https://solarmini.yuntaiqi.com/uploads/20240116/503fa53e688b7b75c44204bfbe2e6ae6.png');
	}

	.yipbox {
		width: 48%;
		padding: 24rpx 32rpx 22rpx 72rpx;
		background-size: 100% 100%;
		background-image: url('https://solarmini.yuntaiqi.com/uploads/20240116/d161d230c623d836790f02191841dc45.png');
	}

	.touxiang {
		width: 110rpx;
		height: 110rpx;
		border-radius: 50%;
	}
</style>